package cn.hiapi.core.basic.query;

import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;

/**
 * @author AdinZ
 * @date 2022/2/22 10:30
 */
@Setter
@Getter
public class CustomQuery {
    /**
     * 自定义外部查询类型
     */
    private String type;
    /**
     * 自定义外部查询值
     */
    private String value;
    /**
     * 关联字段
     */
    private String field;

    public boolean verify() {

        return StringUtils.isNoneEmpty(type) && StringUtils.isNoneEmpty(value);
    }


    @Setter
    @Getter
    public static class Result {

        /**
         * 查询键
         */
        private String key;

        /**
         * 查询值
         */
        private Object value;
        /**
         * 关联字段
         */
        private String field;
        /**
         * type
         */
        private QueryWrapper.Keyword type;

        public static Result of(String type, Object value, String field) {
            Result result = new Result();
            result.setKey(type);
            result.setField(field);
            result.setValue(value);
            return result;
        }
    }

}
